b52665ff597c8a961463fc790f84f11c81bb8479
[tridge/openchange.git] / branches / plugfest / 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 #ifndef _GNU_SOURCE
26 #define _GNU_SOURCE
27 #endif
28
29 #ifndef _PUBLIC_
30 #define _PUBLIC_
31 #endif
32
33 #include <sys/types.h>
34 #include <sys/stat.h>
35
36 #include <stdio.h>
37 #include <unistd.h>
38 #include <stdint.h>
39 #include <stdbool.h>
40
41 #include <tdb.h>
42 #include <ldb.h>
43 #include <talloc.h>
44 #include <util/debug.h>
45
46 #include "libmapi/libmapi.h"
47
48 #include "mapistore_defs.h"
49
50 typedef int (*init_backend_fn) (void);
51
52 #define MAPISTORE_INIT_MODULE   "mapistore_init_backend"
53
54 /* Forward declaration */
55 struct mapistoredb_context;
56
57 struct indexing_context_list;
58
59 struct backend_context {
60         const struct mapistore_backend  *backend;
61         void                            *private_data;
62         struct indexing_context_list    *indexing;
63         uint32_t                        context_id;
64         uint32_t                        ref_count;
65         char                            *uri;
66 };
67
68 struct backend_context_list {
69         struct backend_context          *ctx;
70         struct backend_context_list     *prev;
71         struct backend_context_list     *next;
72 };
73
74 struct processing_context;
75
76 struct mapistore_context {
77         struct processing_context       *processing_ctx;
78         struct backend_context_list     *context_list;
79         struct indexing_context_list    *indexing_list;
80         void                            *nprops_ctx;
81 };
82
83 struct indexing_folders_list {
84         uint64_t                        *folderID;
85         uint32_t                        count;
86 };
87
88 #ifndef __BEGIN_DECLS
89 #ifdef __cplusplus
90 #define __BEGIN_DECLS           extern "C" {
91 #define __END_DECLS             }
92 #else
93 #define __BEGIN_DECLS
94 #define __END_DECLS
95 #endif
96 #endif
97
98 __BEGIN_DECLS
99
100 /* definitions from mapistore_interface.c */
101 struct mapistore_context *mapistore_init(TALLOC_CTX *, const char *);
102 enum MAPISTORE_ERROR mapistore_release(struct mapistore_context *);
103 enum MAPISTORE_ERROR mapistore_add_context(struct mapistore_context *, const char *, uint32_t *);
104 enum MAPISTORE_ERROR mapistore_add_context_ref_count(struct mapistore_context *, uint32_t);
105 enum MAPISTORE_ERROR mapistore_del_context(struct mapistore_context *, uint32_t);
106 enum MAPISTORE_ERROR mapistore_create_uri(struct mapistore_context *, uint32_t, const char *, const char *, char **);
107 enum MAPISTORE_ERROR mapistore_release_record(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
108 enum MAPISTORE_ERROR mapistore_search_context_by_uri(struct mapistore_context *, const char *, uint32_t *);
109 const char *mapistore_errstr(enum MAPISTORE_ERROR);
110 enum MAPISTORE_ERROR mapistore_add_context_indexing(struct mapistore_context *, const char *, uint32_t);
111 enum MAPISTORE_ERROR mapistore_opendir(struct mapistore_context *, uint32_t, uint64_t, uint64_t);
112 enum MAPISTORE_ERROR mapistore_closedir(struct mapistore_context *mstore_ctx, uint32_t, uint64_t);
113 enum MAPISTORE_ERROR mapistore_mkdir(struct mapistore_context *, uint32_t, uint64_t, uint64_t, struct SRow *);
114 enum MAPISTORE_ERROR mapistore_rmdir(struct mapistore_context *, uint32_t, uint64_t, uint64_t, uint8_t);
115 enum MAPISTORE_ERROR mapistore_get_folder_count(struct mapistore_context *, uint32_t, uint64_t, uint32_t *);
116 enum MAPISTORE_ERROR mapistore_get_message_count(struct mapistore_context *, uint32_t, uint64_t, uint32_t *);
117 enum MAPISTORE_ERROR mapistore_get_table_property(struct mapistore_context *, uint32_t, uint8_t, uint64_t, 
118                                                   enum MAPITAGS, uint32_t, void **);
119 enum MAPISTORE_ERROR mapistore_openmessage(struct mapistore_context *, uint32_t, uint64_t, uint64_t, struct mapistore_message *);
120 enum MAPISTORE_ERROR mapistore_createmessage(struct mapistore_context *, uint32_t, uint64_t, uint64_t);
121 enum MAPISTORE_ERROR mapistore_savechangesmessage(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
122 enum MAPISTORE_ERROR mapistore_submitmessage(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
123 enum MAPISTORE_ERROR mapistore_getprops(struct mapistore_context *, uint32_t, uint64_t, uint8_t, struct SPropTagArray *, struct SRow *);
124 enum MAPISTORE_ERROR mapistore_get_fid_by_name(struct mapistore_context *, uint32_t, uint64_t, const char *, uint64_t*);
125 enum MAPISTORE_ERROR mapistore_setprops(struct mapistore_context *, uint32_t, uint64_t, uint8_t, struct SRow *);
126 enum MAPISTORE_ERROR mapistore_get_child_fids(struct mapistore_context *, uint32_t, uint64_t, uint64_t **, uint32_t *);
127 enum MAPISTORE_ERROR mapistore_deletemessage(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
128
129 /* definitions from mapistore_processing.c */
130 enum MAPISTORE_ERROR    mapistore_set_mapping_path(const char *);
131 enum MAPISTORE_ERROR    mapistore_set_database_path(const char *);
132 const char              *mapistore_get_database_path(void);
133 enum MAPISTORE_ERROR    mapistore_set_firstorgdn(const char *, const char *, const char *);
134 const char              *mapistore_get_firstorgdn(void);
135
136 /* definitions from mapistore_backend.c */
137 const char      *mapistore_backend_get_installdir(void);
138 init_backend_fn *mapistore_backend_load(TALLOC_CTX *, const char *);
139 struct backend_context *mapistore_backend_lookup(struct backend_context_list *, uint32_t);
140 struct backend_context *mapistore_backend_lookup_by_uri(struct backend_context_list *, const char *);
141 bool            mapistore_backend_run_init(init_backend_fn *);
142
143 /* definitions from mapistoredb.c */
144 struct mapistoredb_context *mapistoredb_init(TALLOC_CTX *, const char *);
145 void mapistoredb_release(struct mapistoredb_context *);
146 enum MAPISTORE_ERROR mapistoredb_provision(struct mapistoredb_context *);
147 enum MAPISTORE_ERROR mapistoredb_get_mapistore_uri(struct mapistoredb_context *, enum MAPISTORE_DFLT_FOLDERS, const char *, const char *, char **);
148
149 /* definitions from mapistoredb_conf.c */
150 void                            mapistoredb_dump_conf(struct mapistoredb_context *);
151 enum MAPISTORE_ERROR            mapistoredb_set_netbiosname(struct mapistoredb_context *, const char *);
152 enum MAPISTORE_ERROR            mapistoredb_set_firstorg(struct mapistoredb_context *, const char *);
153 enum MAPISTORE_ERROR            mapistoredb_set_firstou(struct mapistoredb_context *, const char *);
154 const char*                     mapistoredb_get_netbiosname(struct mapistoredb_context *);
155 const char*                     mapistoredb_get_firstorg(struct mapistoredb_context *);
156 const char*                     mapistoredb_get_firstou(struct mapistoredb_context *);
157
158 /* definitions from mapistore_indexing.c */
159 enum MAPISTORE_ERROR mapistore_indexing_add(struct mapistore_context *, const char *);
160 enum MAPISTORE_ERROR mapistore_indexing_del(struct mapistore_context *, const char *);
161 enum MAPISTORE_ERROR mapistore_indexing_get_folder_list(struct mapistore_context *, const char *, uint64_t, struct indexing_folders_list **);
162 enum MAPISTORE_ERROR mapistore_indexing_record_add_fid(struct mapistore_context *, uint32_t, uint64_t);
163 enum MAPISTORE_ERROR mapistore_indexing_record_del_fid(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
164 enum MAPISTORE_ERROR mapistore_indexing_record_add_mid(struct mapistore_context *, uint32_t, uint64_t);
165 enum MAPISTORE_ERROR mapistore_indexing_record_del_mid(struct mapistore_context *, uint32_t, uint64_t, uint8_t);
166
167 /* definitions from mapistore_namedprops.c */
168 int mapistore_namedprops_get_mapped_id(void *ldb_ctx, struct MAPINAMEID, uint16_t *);
169
170 __END_DECLS
171
172 #endif  /* ! __MAPISTORE_H */