libmapistore: Switch to using an enum to indicate the type of deletion operation...
[jelmer/openchange.git] / mapiproxy / libmapistore / mapistore.h
1 /*
2    OpenChange Storage Abstraction Layer library
3
4    OpenChange Project
5
6    Copyright (C) Julien Kerihuel 2009-2011
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #ifndef __MAPISTORE_H
23 #define __MAPISTORE_H
24
25 /**
26    \file mapistore.h
27
28    \brief MAPISTORE general API
29    
30    This header contains general functions, primarily for
31    users of the store (rather than storage providers).
32  */
33
34 #ifndef _GNU_SOURCE
35 #define _GNU_SOURCE
36 #endif
37
38 #ifndef _PUBLIC_
39 #define _PUBLIC_
40 #endif
41
42 #include <sys/types.h>
43 #include <sys/stat.h>
44
45 #include <stdio.h>
46 #include <unistd.h>
47 #include <stdint.h>
48 #include <stdbool.h>
49
50 #include <tdb.h>
51 #include <ldb.h>
52 #include <talloc.h>
53 #include <util/debug.h>
54
55 #include "libmapi/libmapi.h"
56
57 #include "mapistore_defs.h"
58
59 typedef int (*init_backend_fn) (void);
60
61 #define MAPISTORE_INIT_MODULE   "mapistore_init_backend"
62
63 /* Forward declaration */
64 struct mapistoredb_context;
65
66 struct indexing_context_list;
67
68 struct backend_context {
69         const struct mapistore_backend  *backend;
70         void                            *private_data;
71         struct indexing_context_list    *indexing;
72         uint32_t                        context_id;
73         uint32_t                        ref_count;
74         char                            *uri;
75 };
76
77 struct backend_context_list {
78         struct backend_context          *ctx;
79         struct backend_context_list     *prev;
80         struct backend_context_list     *next;
81 };
82
83 struct processing_context;
84
85 struct mapistore_context {
86         struct processing_context       *processing_ctx;
87         struct backend_context_list     *context_list;
88         struct indexing_context_list    *indexing_list;
89         void                            *nprops_ctx;
90 };
91
92 struct indexing_folders_list {
93         uint64_t                        *folderID;
94         uint32_t                        count;
95 };
96
97 #ifndef __BEGIN_DECLS
98 #ifdef __cplusplus
99 #define __BEGIN_DECLS           extern "C" {
100 #define __END_DECLS             }
101 #else
102 #define __BEGIN_DECLS
103 #define __END_DECLS
104 #endif
105 #endif
106
107 __BEGIN_DECLS
108
109 /* definitions from mapistore_interface.c */
110 struct mapistore_context *mapistore_init(TALLOC_CTX *, const char *);
111 enum MAPISTORE_ERROR mapistore_release(struct mapistore_context *);
112 enum MAPISTORE_ERROR mapistore_add_context(struct mapistore_context *, const char *, uint32_t *);
113 enum MAPISTORE_ERROR mapistore_add_context_ref_count(struct mapistore_context *, uint32_t);
114 enum MAPISTORE_ERROR mapistore_del_context(struct mapistore_context *, uint32_t);
115 enum MAPISTORE_ERROR mapistore_create_uri(struct mapistore_context *, uint32_t, const char *, const char *, char **);
116 enum MAPISTORE_ERROR mapistore_release_record(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
117 enum MAPISTORE_ERROR mapistore_search_context_by_uri(struct mapistore_context *, const char *, uint32_t *);
118 const char *mapistore_errstr(enum MAPISTORE_ERROR);
119 enum MAPISTORE_ERROR mapistore_add_context_indexing(struct mapistore_context *, const char *, uint32_t);
120 enum MAPISTORE_ERROR mapistore_opendir(struct mapistore_context *, uint32_t, uint64_t, uint64_t);
121 enum MAPISTORE_ERROR mapistore_closedir(struct mapistore_context *mstore_ctx, uint32_t, uint64_t);
122 enum MAPISTORE_ERROR mapistore_mkdir(struct mapistore_context *, uint32_t, uint64_t, uint64_t, struct SRow *);
123 enum MAPISTORE_ERROR mapistore_rmdir(struct mapistore_context *, uint32_t, uint64_t, uint64_t, uint8_t);
124 enum MAPISTORE_ERROR mapistore_get_folder_count(struct mapistore_context *, uint32_t, uint64_t, uint32_t *);
125 enum MAPISTORE_ERROR mapistore_get_message_count(struct mapistore_context *, uint32_t, uint64_t, uint32_t *);
126 enum MAPISTORE_ERROR mapistore_get_table_property(struct mapistore_context *, uint32_t, enum MAPISTORE_TABLE_TYPE, uint64_t, 
127                                                   enum MAPITAGS, uint32_t, void **);
128 enum MAPISTORE_ERROR mapistore_openmessage(struct mapistore_context *, uint32_t, uint64_t, uint64_t, struct mapistore_message *);
129 enum MAPISTORE_ERROR mapistore_createmessage(struct mapistore_context *, uint32_t, uint64_t, uint64_t);
130 enum MAPISTORE_ERROR mapistore_savechangesmessage(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
131 enum MAPISTORE_ERROR mapistore_submitmessage(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
132 enum MAPISTORE_ERROR mapistore_getprops(struct mapistore_context *, uint32_t, uint64_t, uint8_t, struct SPropTagArray *, struct SRow *);
133 enum MAPISTORE_ERROR mapistore_get_fid_by_name(struct mapistore_context *, uint32_t, uint64_t, const char *, uint64_t*);
134 enum MAPISTORE_ERROR mapistore_setprops(struct mapistore_context *, uint32_t, uint64_t, uint8_t, struct SRow *);
135 enum MAPISTORE_ERROR mapistore_get_child_fids(struct mapistore_context *, uint32_t, uint64_t, uint64_t **, uint32_t *);
136 enum MAPISTORE_ERROR mapistore_deletemessage(struct mapistore_context *, uint32_t, uint64_t, enum MAPISTORE_DELETION_TYPE);
137
138 /* definitions from mapistore_processing.c */
139 enum MAPISTORE_ERROR    mapistore_set_mapping_path(const char *);
140 enum MAPISTORE_ERROR    mapistore_set_database_path(const char *);
141 const char              *mapistore_get_database_path(void);
142 enum MAPISTORE_ERROR    mapistore_set_firstorgdn(const char *, const char *, const char *);
143 const char              *mapistore_get_firstorgdn(void);
144
145 /* definitions from mapistore_backend.c */
146 const char      *mapistore_backend_get_installdir(void);
147 init_backend_fn *mapistore_backend_load(TALLOC_CTX *, const char *);
148 struct backend_context *mapistore_backend_lookup(struct backend_context_list *, uint32_t);
149 struct backend_context *mapistore_backend_lookup_by_uri(struct backend_context_list *, const char *);
150 bool            mapistore_backend_run_init(init_backend_fn *);
151
152 /* definitions from mapistoredb.c */
153 struct mapistoredb_context *mapistoredb_init(TALLOC_CTX *, const char *);
154 void mapistoredb_release(struct mapistoredb_context *);
155 enum MAPISTORE_ERROR mapistoredb_provision(struct mapistoredb_context *);
156 enum MAPISTORE_ERROR mapistoredb_get_mapistore_uri(struct mapistoredb_context *, enum MAPISTORE_DFLT_FOLDERS, const char *, const char *, char **);
157 enum MAPISTORE_ERROR mapistoredb_get_new_fmid(struct mapistoredb_context *, uint64_t *);
158 enum MAPISTORE_ERROR mapistoredb_get_new_allocation_range(struct mapistoredb_context *, uint64_t, uint64_t *, uint64_t *);
159
160 /* definitions from mapistoredb_conf.c */
161 void                            mapistoredb_dump_conf(struct mapistoredb_context *);
162 enum MAPISTORE_ERROR            mapistoredb_set_netbiosname(struct mapistoredb_context *, const char *);
163 enum MAPISTORE_ERROR            mapistoredb_set_firstorg(struct mapistoredb_context *, const char *);
164 enum MAPISTORE_ERROR            mapistoredb_set_firstou(struct mapistoredb_context *, const char *);
165 const char*                     mapistoredb_get_netbiosname(struct mapistoredb_context *);
166 const char*                     mapistoredb_get_firstorg(struct mapistoredb_context *);
167 const char*                     mapistoredb_get_firstou(struct mapistoredb_context *);
168
169 /* definitions from mapistore_indexing.c */
170 enum MAPISTORE_ERROR mapistore_indexing_add(struct mapistore_context *, const char *);
171 enum MAPISTORE_ERROR mapistore_indexing_del(struct mapistore_context *, const char *);
172 enum MAPISTORE_ERROR mapistore_indexing_get_folder_list(struct mapistore_context *, const char *, uint64_t, struct indexing_folders_list **);
173 enum MAPISTORE_ERROR mapistore_indexing_record_add_fid(struct mapistore_context *, uint32_t, uint64_t);
174 enum MAPISTORE_ERROR mapistore_indexing_record_del_fid(struct mapistore_context *, uint32_t, uint64_t, enum MAPISTORE_DELETION_TYPE);
175 enum MAPISTORE_ERROR mapistore_indexing_record_add_mid(struct mapistore_context *, uint32_t, uint64_t);
176 enum MAPISTORE_ERROR mapistore_indexing_record_del_mid(struct mapistore_context *, uint32_t, uint64_t, enum MAPISTORE_DELETION_TYPE);
177
178 /* definitions from mapistore_namedprops.c */
179 int mapistore_namedprops_get_mapped_id(void *ldb_ctx, struct MAPINAMEID, uint16_t *);
180
181 __END_DECLS
182
183 #endif  /* ! __MAPISTORE_H */