addrindex.h (5566B)
1 /* 2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client 3 * Copyright (C) 2001-2012 Match Grun and the Claws Mail team 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 3 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, see <http://www.gnu.org/licenses/>. 17 * 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 #include "addrquery.h" 32 33 #define ADDRESSBOOK_MAX_IFACE 4 34 #define ADDRESSBOOK_INDEX_FILE "addrbook--index.xml" 35 #define ADDRESSBOOK_OLD_FILE "addressbook.xml" 36 37 typedef enum { 38 ADDR_IF_NONE, 39 ADDR_IF_BOOK, 40 ADDR_IF_COMMON, 41 ADDR_IF_PERSONAL 42 } AddressIfType; 43 44 typedef struct _AddressIndex AddressIndex; 45 struct _AddressIndex { 46 AddrItemObject obj; 47 gchar *filePath; 48 gchar *fileName; 49 gint retVal; 50 gboolean needsConversion; 51 gboolean wasConverted; 52 gboolean conversionError; 53 AddressIfType lastType; 54 gboolean dirtyFlag; 55 GList *interfaceList; 56 GHashTable *hashCache; 57 gboolean loadedFlag; 58 GList *searchOrder; 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 gboolean externalQuery; 86 gint searchOrder; 87 void (*startSearch)( void * ); 88 void (*stopSearch)( void * ); 89 }; 90 91 typedef struct _AddressDataSource AddressDataSource; 92 struct _AddressDataSource { 93 AddrItemObject obj; 94 AddressIfType type; 95 AddressInterface *interface; 96 gpointer rawDataSource; 97 }; 98 99 void addrindex_initialize ( void ); 100 void addrindex_teardown ( void ); 101 102 AddressIndex *addrindex_create_index ( void ); 103 void addrindex_set_file_path ( AddressIndex *addrIndex, 104 const gchar *value ); 105 void addrindex_set_file_name ( AddressIndex *addrIndex, 106 const gchar *value ); 107 108 GList *addrindex_get_interface_list ( AddressIndex *addrIndex ); 109 void addrindex_free_index ( AddressIndex *addrIndex ); 110 void addrindex_print_index ( AddressIndex *addrIndex, FILE *stream ); 111 112 113 AddressDataSource *addrindex_index_add_datasource ( AddressIndex *addrIndex, 114 AddressIfType ifType, 115 gpointer dataSource ); 116 AddressDataSource *addrindex_index_remove_datasource ( AddressIndex *addrIndex, 117 AddressDataSource *dataSource ); 118 119 void addrindex_free_datasource ( AddressDataSource *ds ); 120 gchar *addrindex_get_cache_id ( AddressIndex *addrIndex, 121 AddressDataSource *ds ); 122 AddressCache *addrindex_get_cache ( AddressIndex *addrIndex, 123 const gchar *cacheID ); 124 125 gint addrindex_read_data ( AddressIndex *addrIndex ); 126 gint addrindex_save_data ( AddressIndex *addrIndex ); 127 gint addrindex_create_new_books ( AddressIndex *addrIndex ); 128 gint addrindex_save_all_books ( AddressIndex *addrIndex ); 129 130 gboolean addrindex_ds_get_modify_flag ( AddressDataSource *ds ); 131 gboolean addrindex_ds_get_access_flag ( AddressDataSource *ds ); 132 gboolean addrindex_ds_get_read_flag ( AddressDataSource *ds ); 133 gint addrindex_ds_get_status_code ( AddressDataSource *ds ); 134 gint addrindex_ds_read_data ( AddressDataSource *ds ); 135 ItemFolder *addrindex_ds_get_root_folder( AddressDataSource *ds ); 136 gchar *addrindex_ds_get_name ( AddressDataSource *ds ); 137 void addrindex_ds_set_access_flag ( AddressDataSource *ds, 138 gboolean *value ); 139 gboolean addrindex_ds_get_readonly ( AddressDataSource *ds ); 140 141 /* Search support */ 142 gint addrindex_setup_search ( const gchar *searchTerm, 143 void *callBackEnd, 144 void *callBackEntry ); 145 146 gint addrindex_setup_static_search ( AddressDataSource *ds, 147 const gchar *searchTerm, 148 ItemFolder *folder, 149 void *callBackEnd, 150 void *callBackEntry ); 151 152 gboolean addrindex_start_search ( const gint queryID ); 153 void addrindex_stop_search ( const gint queryID ); 154 gint addrindex_setup_explicit_search ( AddressDataSource *ds, 155 const gchar *searchTerm, 156 ItemFolder *folder, 157 void *callBackEnd, 158 void *callBackEntry ); 159 void addrindex_remove_results ( AddressDataSource *ds, 160 ItemFolder *folder ); 161 162 gboolean addrindex_load_completion( 163 gint (*callBackFunc) 164 ( const gchar *, const gchar *, 165 const gchar *, const gchar *, GList * ), 166 gchar *folderpath ); 167 168 gboolean addrindex_load_person_attribute( const gchar *attr, 169 gint (*callBackFunc) 170 ( ItemPerson *, const gchar * ) ); 171 172 gboolean addrindex_load_person_ds( gint (*callBackFunc) 173 ( ItemPerson *, AddressDataSource * ) ); 174 gchar *addrindex_get_picture_file(const gchar *emailaddr); 175 176 #endif /* __ADDRINDEX_H__ */