upd jpilot, fix editldap_basedn
[claws.git] / src / addrindex.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2001 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
31 #define ADDRESSBOOK_MAX_IFACE  4
32 #define ADDRESSBOOK_INDEX_FILE "addrbook--index.xml"
33 #define ADDRESSBOOK_OLD_FILE   "addressbook.xml"
34
35 typedef enum {
36         ADDR_IF_NONE,
37         ADDR_IF_BOOK,
38         ADDR_IF_VCARD,
39         ADDR_IF_JPILOT,
40         ADDR_IF_LDAP,
41         ADDR_IF_COMMON,
42         ADDR_IF_PERSONAL
43 } AddressIfType;
44
45 typedef struct _AddressIndex AddressIndex;
46 struct _AddressIndex {
47         AddrItemObject obj;
48         gchar *filePath;
49         gchar *fileName;
50         gint  retVal;
51         gboolean needsConversion;
52         gboolean wasConverted;
53         gboolean conversionError;
54         AddressIfType lastType;
55         gboolean dirtyFlag;
56         GList *interfaceList;
57 };
58
59 typedef struct _AddressInterface AddressInterface;
60 struct _AddressInterface {
61         AddrItemObject obj;
62         AddressIfType type;
63         gchar *name;
64         gchar *listTag;
65         gchar *itemTag;
66         gboolean legacyFlag;
67         gboolean useInterface;
68         gboolean haveLibrary;
69         gboolean readOnly;
70         GList *listSource;
71         gboolean (*getModifyFlag)( void * );
72         gboolean (*getAccessFlag)( void * );
73         gboolean (*getReadFlag)( void * );
74         gint (*getStatusCode)( void * );
75         gint (*getReadData)( void * );
76         ItemFolder *(*getRootFolder)( void * );
77         GList *(*getListFolder)( void * );
78         GList *(*getListPerson)( void * );
79         GList *(*getAllPersons)( void * );
80         GList *(*getAllGroups)( void * );
81         gchar *(*getName) ( void * );
82         void (*setAccessFlag)( void *, void * );
83 };
84
85 typedef struct _AddressDataSource AddressDataSource;
86 struct _AddressDataSource {
87         AddrItemObject obj;
88         AddressIfType type;
89         AddressInterface *interface;
90         gpointer rawDataSource;
91 };
92
93 AddressIndex *addrindex_create_index    ();
94 void addrindex_set_file_path            ( AddressIndex *addrIndex, const gchar *value );
95 void addrindex_set_file_name            ( AddressIndex *addrIndex, const gchar *value );
96 void addrindex_set_dirty                ( AddressIndex *addrIndex, const gboolean value );
97 GList *addrindex_get_interface_list     ( AddressIndex *addrIndex );
98 void addrindex_free_index               ( AddressIndex *addrIndex );
99 void addrindex_print_index              ( AddressIndex *addrIndex, FILE *stream );
100
101 AddressInterface *addrindex_get_interface               ( AddressIndex *addrIndex, AddressIfType ifType );
102 AddressDataSource *addrindex_index_add_datasource       ( AddressIndex *addrIndex, AddressIfType ifType, gpointer dataSource );
103 AddressDataSource *addrindex_index_remove_datasource    ( AddressIndex *addrIndex, AddressDataSource *dataSource );
104 void addrindex_free_datasource          ( AddressIndex *addrIndex, AddressDataSource *ds );
105
106 gint addrindex_read_data                ( AddressIndex *addrIndex );
107 gint addrindex_write_to                 ( AddressIndex *addrIndex, const gchar *newFile );
108 gint addrindex_save_data                ( AddressIndex *addrIndex );
109 gint addrindex_create_new_books         ( AddressIndex *addrIndex );
110 gint addrindex_save_all_books           ( AddressIndex *addrIndex );
111
112 gboolean addrindex_ds_get_modify_flag   ( AddressDataSource *ds );
113 gboolean addrindex_ds_get_access_flag   ( AddressDataSource *ds );
114 gboolean addrindex_ds_get_read_flag     ( AddressDataSource *ds );
115 gint addrindex_ds_get_status_code       ( AddressDataSource *ds );
116 gint addrindex_ds_read_data             ( AddressDataSource *ds );
117 ItemFolder *addrindex_ds_get_root_folder( AddressDataSource *ds );
118 GList *addrindex_ds_get_list_folder     ( AddressDataSource *ds );
119 GList *addrindex_ds_get_list_person     ( AddressDataSource *ds );
120 gchar *addrindex_ds_get_name            ( AddressDataSource *ds );
121 void addrindex_ds_set_access_flag       ( AddressDataSource *ds, gboolean *value );
122 gboolean addrindex_ds_get_readonly      ( AddressDataSource *ds );
123 GList *addrindex_ds_get_all_persons     ( AddressDataSource *ds );
124 GList *addrindex_ds_get_all_groups      ( AddressDataSource *ds );
125
126 #endif /* __ADDRINDEX_H__ */
127
128 /*
129 * End of Source.
130 */
131
132