~ubuntu-branches/debian/sid/openchange/sid

« back to all changes in this revision

Viewing changes to mapiproxy/libmapistore/mapistore_backend.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-12 20:07:57 UTC
  • mfrom: (11 sid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20120412200757-k933d9trljmxj1l4
Tags: 1:1.0-4
* openchangeserver: Add dependency on openchangeproxy.
* Rebuild against newer version of Samba 4.
* Use dpkg-buildflags.
* Migrate to Git, update Vcs-Git header.
* Switch to debhelper 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
   OpenChange Project
5
5
 
6
6
   Note: init and load functions have been copied from
7
 
   samba4/source4/param/util.c initially written by Jelmer.
 
7
   samba4/source4/param/util.c initially wrote by Jelmer.
8
8
 
9
9
   Copyright (C) Jelmer Vernooij 2005-2007
10
 
   Copyright (C) Julien Kerihuel 2009-2011
 
10
   Copyright (C) Julien Kerihuel 2009
11
11
 
12
12
   This program is free software; you can redistribute it and/or modify
13
13
   it under the terms of the GNU General Public License as published by
28
28
#include <dlfcn.h>
29
29
#include <dirent.h>
30
30
 
 
31
#include "mapistore.h"
31
32
#include "mapistore_errors.h"
32
 
#include "mapistore.h"
33
33
#include "mapistore_private.h"
34
 
#include "mapistore_backend.h"
35
 
#include "mapistore_common.h"
36
34
#include <dlinklist.h>
37
35
 
38
 
#include <util.h>
 
36
#include <samba_util.h>
39
37
#include <util/debug.h>
40
38
 
41
39
/**
51
49
 
52
50
int                                     num_backends;
53
51
 
 
52
 
54
53
/**
55
 
  \brief Register a backend
56
 
 
57
 
  This function registers a backend with mapistore.
58
 
 
59
 
  The general approach is to create a mapistore_backend object within the 
60
 
  mapistore_init_backend() entry point, fill in the various structure elements
61
 
  and function pointers, and then call mapistore_backend_register().
62
 
 
63
 
  \code
64
 
  enum MAPISTORE_ERROR mapistore_init_backend(void)
65
 
  {
66
 
    enum MAPISTORE_ERROR        retval;
67
 
    struct mapistore_backend    demo_backend;
68
 
 
69
 
    retval = mapistore_backend_init_defaults(&demo_backend);
70
 
    MAPISTORE_RETVAL_IF(retval, retval, NULL);
71
 
 
72
 
    demo_backend.name = "demo";
73
 
    demo_backend.description = "this is just a demostration of the mapistore backend API";
74
 
    demo_backend.uri_namespace = "demo://";
75
 
    demo.init = demo_init; // calls demo_init() on startup
76
 
    ... // more function pointers here.
77
 
    
78
 
    mapistore_backend_register(&demo_backend);
79
 
    if (retval != MAPISTORE_SUCCESS) {
80
 
        MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "Failed to register the '%s' mapistore backend\n", demo_backend.name);
81
 
        return retval;
82
 
    }
83
 
 
84
 
    return MAPISTORE_SUCCESS;
85
 
  }
86
 
  \endcode
87
 
 
88
 
  \param backend pointer to the mapistore backend to register
89
 
 
90
 
  \return MAPISTORE_SUCCESS on success
 
54
   \details Register mapistore backends
 
55
 
 
56
   \param backend pointer to the mapistore backend to register
 
57
 
 
58
   \return MAPISTORE_SUCCESS on success
91
59
 */
92
 
_PUBLIC_ enum MAPISTORE_ERROR mapistore_backend_register(const struct mapistore_backend *backend)
 
60
_PUBLIC_ enum mapistore_error mapistore_backend_register(const void *_backend)
93
61
{
94
 
        int                             i;
 
62
        const struct mapistore_backend  *backend = _backend;
 
63
        uint32_t                        i;
95
64
 
96
65
        /* Sanity checks */
97
66
        MAPISTORE_RETVAL_IF(!backend, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
98
67
 
99
68
        for (i = 0; i < num_backends; i++) {
100
69
                if (backends[i].backend && backend && 
101
 
                    backend->name && backends[i].backend->name &&
102
 
                    !strcmp(backends[i].backend->name, backend->name)) {
103
 
                        MSTORE_DEBUG_INFO(MSTORE_LEVEL_NORMAL, "MAPISTORE backend '%s' already registered\n", backend->name);
 
70
                    backend->backend.name && backends[i].backend->backend.name &&
 
71
                    !strcmp(backends[i].backend->backend.name, backend->backend.name)) {
 
72
                        DEBUG(3, ("MAPISTORE backend '%s' already registered\n", backend->backend.name));
104
73
                        return MAPISTORE_SUCCESS;
105
74
                }
106
75
        }
110
79
                smb_panic("out of memory in mapistore_backend_register");
111
80
        }
112
81
 
113
 
        backends[num_backends].backend = (struct mapistore_backend *)smb_xmemdup(backend, sizeof (*backend));
114
 
        backends[num_backends].backend->name = smb_xstrdup(backend->name);
 
82
        backends[num_backends].backend = smb_xmemdup(backend, sizeof (*backend));
 
83
        backends[num_backends].backend->backend.name = smb_xstrdup(backend->backend.name);
115
84
 
116
85
        num_backends++;
117
86
 
118
 
        MSTORE_DEBUG_INFO(MSTORE_LEVEL_NORMAL, "MAPISTORE backend '%s' registered\n", backend->name);
 
87
        DEBUG(3, ("MAPISTORE backend '%s' registered\n", backend->backend.name));
119
88
 
120
89
        return MAPISTORE_SUCCESS;
121
90
}
122
91
 
 
92
/**
 
93
   \details Check if the specified backend is registered given its
 
94
   name.
 
95
 
 
96
   \param name backend's name to lookup
 
97
 
 
98
   \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
 
99
 */
 
100
_PUBLIC_ enum mapistore_error mapistore_backend_registered(const char *name)
 
101
{
 
102
        int     i;
 
103
 
 
104
        /* Sanity checks */
 
105
        MAPISTORE_RETVAL_IF(!name, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
 
106
 
 
107
        for (i = 0; i < num_backends; i++) {
 
108
                if (backends[i].backend && !strcmp(backends[i].backend->backend.name, name)) {
 
109
                        return MAPISTORE_SUCCESS;
 
110
                }
 
111
        }
 
112
 
 
113
        return MAPISTORE_ERR_NOT_FOUND;
 
114
}
 
115
 
123
116
 
124
117
/**
125
118
   \details Return the full path where mapistore backends are
133
126
}
134
127
 
135
128
 
 
129
 
136
130
/**
137
131
   \details Obtain the backend init function from a shared library
138
132
   file
149
143
 
150
144
        handle = dlopen(path, RTLD_NOW);
151
145
        if (handle == NULL) {
152
 
                MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "Unable to open %s: %s\n", path, dlerror())
 
146
                DEBUG(0, ("Unable to open %s: %s\n", path, dlerror()));
153
147
                return NULL;
154
148
        }
155
149
 
156
150
        init_fn = dlsym(handle, MAPISTORE_INIT_MODULE);
157
151
 
158
152
        if (init_fn == NULL) {
159
 
                MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "Unable to find %s() in %s: %s\n",
160
 
                                   MAPISTORE_INIT_MODULE, path, dlerror());
161
 
                MSTORE_DEBUG_ERROR(MSTORE_LEVEL_HIGH, "Loading mapistore backend '%s' failed\n", path);
 
153
                DEBUG(0, ("Unable to find %s() in %s: %s\n",
 
154
                          MAPISTORE_INIT_MODULE, path, dlerror()));
 
155
                DEBUG(1, ("Loading mapistore backend '%s' failed\n", path));
162
156
                dlclose(handle);
163
157
                return NULL;
164
158
        }
258
252
        return ret;
259
253
}
260
254
 
 
255
 
261
256
/**
262
257
   \details Initialize mapistore backends
263
258
 
268
263
   \return MAPISTORE_SUCCESS on success, otherwise
269
264
   MAPISTORE_ERR_BACKEND_INIT
270
265
 */
271
 
enum MAPISTORE_ERROR mapistore_backend_init(TALLOC_CTX *mem_ctx, const char *path)
 
266
enum mapistore_error mapistore_backend_init(TALLOC_CTX *mem_ctx, const char *path)
272
267
{
273
268
        init_backend_fn                 *ret;
274
269
        bool                            status;
275
 
        enum MAPISTORE_ERROR            retval;
 
270
        int                             retval;
276
271
        int                             i;
277
272
 
278
273
        ret = mapistore_backend_load(mem_ctx, path);
281
276
 
282
277
        for (i = 0; i < num_backends; i++) {
283
278
                if (backends[i].backend) {
284
 
                        MSTORE_DEBUG_INFO(MSTORE_LEVEL_NORMAL, "MAPISTORE backend '%s' loaded\n", backends[i].backend->name);
285
 
                        retval = backends[i].backend->init();
 
279
                        retval = backends[i].backend->backend.init();
286
280
                        if (retval != MAPISTORE_SUCCESS) {
287
 
                                 return retval;
288
 
                         }
289
 
                 }
290
 
         }
291
 
 
292
 
         return (status != true) ? MAPISTORE_SUCCESS : MAPISTORE_ERR_BACKEND_INIT;
293
 
 }
294
 
 
295
 
 
296
 
enum MAPISTORE_ERROR mapistore_backend_get_next_backend(const char **backend_name,
297
 
                                                        const char **backend_namespace,
298
 
                                                        const char **backend_description,
299
 
                                                        uint32_t *backend_index)
 
281
                                DEBUG(3, ("[!] MAPISTORE backend '%s' initialization failed\n", backends[i].backend->backend.name));
 
282
                        } else {
 
283
                                DEBUG(3, ("MAPISTORE backend '%s' loaded\n", backends[i].backend->backend.name));
 
284
                        }
 
285
                }
 
286
        }
 
287
 
 
288
        return (status != true) ? MAPISTORE_SUCCESS : MAPISTORE_ERR_BACKEND_INIT;
 
289
}
 
290
 
 
291
/**
 
292
   \details List backend contexts for given user
 
293
 
 
294
   \param mem_ctx pointer to the memory context
 
295
   \param namespace the backend namespace
 
296
   \param uri the backend parameters which can be passes inline
 
297
 
 
298
   \return a valid backend_context pointer on success, otherwise NULL
 
299
 */
 
300
enum mapistore_error mapistore_backend_list_contexts(const char *username, struct tdb_wrap *tdbwrap, TALLOC_CTX *mem_ctx, struct mapistore_contexts_list **contexts_listP)
300
301
{
301
 
        int     i;
302
 
 
303
 
        /* Sanity checks */
304
 
        MAPISTORE_RETVAL_IF(!backend_name, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
305
 
        MAPISTORE_RETVAL_IF(!backend_namespace, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
306
 
        MAPISTORE_RETVAL_IF(!backend_description, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
307
 
        MAPISTORE_RETVAL_IF(!backend_index, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
308
 
 
309
 
        i = *backend_index;
310
 
        MAPISTORE_RETVAL_IF((i >= num_backends), MAPISTORE_ERR_NOT_FOUND, NULL);
311
 
        MAPISTORE_RETVAL_IF(!backends[i].backend, MAPISTORE_ERR_NOT_FOUND, NULL);
312
 
 
313
 
        *backend_name = backends[i].backend->name;
314
 
        *backend_namespace = backends[i].backend->uri_namespace;
315
 
        *backend_description = backends[i].backend->description;
316
 
        *backend_index += 1;
 
302
        enum mapistore_error            retval;
 
303
        int                             i;
 
304
        struct mapistore_contexts_list  *contexts_list = NULL, *current_contexts_list;
 
305
 
 
306
        MAPISTORE_RETVAL_IF(!username, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
 
307
        MAPISTORE_RETVAL_IF(!contexts_listP, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
 
308
 
 
309
        for (i = 0; i < num_backends; i++) {
 
310
                retval = backends[i].backend->backend.list_contexts(username, tdbwrap, mem_ctx, &current_contexts_list);
 
311
                if (retval != MAPISTORE_SUCCESS) {
 
312
                        return retval;
 
313
                }
 
314
                DLIST_CONCATENATE(contexts_list, current_contexts_list, void);
 
315
        }
 
316
 
 
317
        *contexts_listP = contexts_list;
 
318
        (void) talloc_reference(mem_ctx, contexts_list);
317
319
 
318
320
        return MAPISTORE_SUCCESS;
319
321
}
320
322
 
321
323
/**
322
 
   \details Return the LDIF data associated to a mapistore backend
323
 
 
324
 
   \param mem_ctx pointer to the mapistore context
325
 
   \param backend_name pointer to the backend name to retrieve LDIF data from
326
 
   \param ldif pointer on pointer to the LDIF data to return
327
 
   \param ntype pointer to the LDIF provision data type to return
328
 
 
329
 
   \return MAPISTORE_SUCCESS on success, MAPISTORE_ERR_NOT_FOUND if
330
 
   the specified backend name was not found,
331
 
   MAPSITORE_ERR_NOT_IMPLEMENTED if the backend doesn't handle the
332
 
   ldif op, otherwise MAPISTORE error
 
324
   \details Create backend context
 
325
 
 
326
   \param mem_ctx pointer to the memory context
 
327
   \param namespace the backend namespace
 
328
   \param uri the backend parameters which can be passes inline
 
329
 
 
330
   \return a valid backend_context pointer on success, otherwise NULL
333
331
 */
334
 
enum MAPISTORE_ERROR mapistore_backend_get_namedprops_ldif(TALLOC_CTX *mem_ctx,
335
 
                                                           const char *backend_name,
336
 
                                                           char **ldif,
337
 
                                                           enum MAPISTORE_NAMEDPROPS_PROVISION_TYPE *ntype)
 
332
enum mapistore_error mapistore_backend_create_context(TALLOC_CTX *mem_ctx, struct mapistore_connection_info *conn_info, struct tdb_wrap *tdbwrap,
 
333
                                                      const char *namespace, const char *uri, uint64_t fid, struct backend_context **context_p)
338
334
{
339
 
        enum MAPISTORE_ERROR                            retval;
340
 
        enum MAPISTORE_NAMEDPROPS_PROVISION_TYPE        _ntype;
341
 
        char                                            *_ldif;
342
 
        int                                             i;
343
 
 
344
 
        /* Sanity checks */
345
 
        MAPISTORE_RETVAL_IF(!ldif, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
346
 
        MAPISTORE_RETVAL_IF(!backend_name, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
347
 
        MAPISTORE_RETVAL_IF(!ntype, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
 
335
        struct backend_context          *context;
 
336
        enum mapistore_error            retval;
 
337
        bool                            found = false;
 
338
        void                            *backend_object = NULL;
 
339
        int                             i;
 
340
 
 
341
        DEBUG(0, ("namespace is %s and backend_uri is '%s'\n", namespace, uri));
 
342
 
 
343
        context = talloc_zero(NULL, struct backend_context);
348
344
 
349
345
        for (i = 0; i < num_backends; i++) {
350
 
                if (backends[i].backend && backends[i].backend->name && 
351
 
                    !strncmp(backends[i].backend->name, backend_name, strlen(backends[i].backend->name))) {
 
346
                if (backends[i].backend->backend.namespace && 
 
347
                    !strcmp(namespace, backends[i].backend->backend.namespace)) {
 
348
                        found = true;
 
349
                        retval = backends[i].backend->backend.create_context(context, conn_info, tdbwrap, uri, &backend_object);
 
350
                        if (retval != MAPISTORE_SUCCESS) {
 
351
                                goto end;
 
352
                        }
 
353
 
352
354
                        break;
353
355
                }
354
356
        }
355
357
 
356
 
        if (i >= num_backends) return MAPISTORE_ERR_NOT_FOUND;
357
 
 
358
 
        retval = backends[i].backend->op_db_provision_namedprops(mem_ctx, &_ldif, &_ntype);
359
 
        MAPISTORE_RETVAL_IF(retval, retval, NULL);
360
 
 
361
 
        if (_ldif && _ntype != MAPISTORE_NAMEDPROPS_PROVISION_NONE) {
362
 
                *ldif = talloc_strdup(mem_ctx, _ldif);
363
 
                talloc_free(_ldif);
364
 
        }
365
 
 
366
 
        *ntype = _ntype;
367
 
        
368
 
        return retval;
369
 
}
370
 
 
371
 
 
372
 
static enum MAPISTORE_ERROR delete_context(void *data)
373
 
 {
374
 
         struct backend_context         *context = (struct backend_context *) data;
375
 
 
376
 
         context->backend->delete_context(context->private_data);
377
 
 
378
 
         return MAPISTORE_SUCCESS;
379
 
 }
380
 
 
381
 
 /**
382
 
    \details Create backend context
383
 
 
384
 
    \param mem_ctx pointer to the memory context
385
 
    \param login_user the username used for authentication
386
 
    \param username the username we want to impersonate
387
 
    \param uri_namespace the backend namespace
388
 
    \param uri the backend parameters which can be passes inline
389
 
 
390
 
    \return a valid backend_context pointer on success, otherwise NULL
391
 
  */
392
 
 struct backend_context *mapistore_backend_create_context(TALLOC_CTX *mem_ctx, 
393
 
                                                          const char *login_user,
394
 
                                                          const char *username,
395
 
                                                          const char *uri_namespace, 
396
 
                                                          const char *uri)
397
 
 {
398
 
         struct backend_context         *context;
399
 
         int                            retval;
400
 
         bool                           found = false;
401
 
         void                           *private_data = NULL;
402
 
         int                            i;
403
 
 
404
 
         MSTORE_DEBUG_INFO(MSTORE_LEVEL_INFO, "namespace is %s and backend URI is %s\n", uri_namespace, uri);
405
 
         for (i = 0; i < num_backends; i++) {
406
 
                 if (backends[i].backend->uri_namespace && 
407
 
                     !strcmp(uri_namespace, backends[i].backend->uri_namespace)) {
408
 
                         found = true;
409
 
                         retval = backends[i].backend->create_context(mem_ctx, login_user, username, uri, &private_data);
410
 
                         if (retval != MAPISTORE_SUCCESS) {
411
 
                                 MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "Failed to create context for backend '%s': %s\n",
412
 
                                                    backends[i].backend->name, mapistore_errstr(retval));
413
 
                                 return NULL;
414
 
                         }
415
 
 
416
 
                         break;
417
 
                 }
418
 
         }
419
 
         if (found == false) {
420
 
                 MSTORE_DEBUG_ERROR(MSTORE_LEVEL_CRITICAL, "No backend with namespace '%s' is available\n", uri_namespace);
421
 
                 return NULL;
422
 
         }
423
 
 
424
 
         context = talloc_zero(mem_ctx, struct backend_context);
425
 
         talloc_set_destructor((void *)context, (int (*)(void *))delete_context);
426
 
         context->backend = backends[i].backend;
427
 
         context->private_data = private_data;
428
 
         context->ref_count = 0;
429
 
         context->uri = talloc_strdup(context, uri);
430
 
         talloc_steal(context, private_data);
431
 
 
432
 
         return context;
433
 
 }
434
 
 
435
 
 /**
436
 
    \details Increase the ref count associated to a given backend
437
 
 
438
 
    \param bctx pointer to the backend context
439
 
 
440
 
    \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
441
 
  */
442
 
 _PUBLIC_ enum MAPISTORE_ERROR mapistore_backend_add_ref_count(struct backend_context *bctx)
443
 
 {
444
 
         /* Sanity checks */
445
 
         MAPISTORE_RETVAL_IF(!bctx, MAPISTORE_ERROR, NULL);
446
 
 
447
 
         bctx->ref_count += 1;
448
 
 
449
 
         return MAPISTORE_SUCCESS;
450
 
 }
451
 
 
452
 
 
453
 
 /**
454
 
    \details Delete a context from the specified backend
455
 
 
456
 
    \param bctx pointer to the backend context
457
 
 
458
 
    \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
459
 
  */
460
 
 _PUBLIC_ enum MAPISTORE_ERROR mapistore_backend_delete_context(struct backend_context *bctx)
461
 
 {
462
 
         enum MAPISTORE_ERROR   retval;
463
 
 
464
 
         /* Sanity checks */
465
 
         MAPISTORE_RETVAL_IF(!bctx->backend->delete_context, MAPISTORE_ERROR, NULL);
466
 
 
467
 
         if (bctx->indexing) {
468
 
                 retval = mapistore_indexing_del_ref_count(bctx->indexing);
469
 
         }
470
 
 
471
 
         if (bctx->ref_count) {
472
 
                 bctx->ref_count -= 1;
473
 
                 return MAPISTORE_ERR_REF_COUNT;
474
 
         }
475
 
 
476
 
         retval = bctx->backend->delete_context(bctx->private_data);
477
 
         talloc_set_destructor((void *)bctx, NULL);
478
 
 
479
 
         return retval;
480
 
 }
481
 
 
482
 
 
483
 
 _PUBLIC_ enum MAPISTORE_ERROR mapistore_backend_release_record(struct backend_context *bctx, const char *uri, uint8_t type)
484
 
 {
485
 
         return bctx->backend->release_record(bctx->private_data, uri, type);
486
 
 }
487
 
 
488
 
 
489
 
_PUBLIC_ enum MAPISTORE_ERROR mapistore_backend_create_uri(TALLOC_CTX *mem_ctx, 
490
 
                                                           enum MAPISTORE_DFLT_FOLDERS index, 
491
 
                                                           const char *uri_namespace,
492
 
                                                           const char *username, 
493
 
                                                           char **uri)
494
 
{
495
 
        enum MAPISTORE_ERROR    retval;
496
 
        char                    *_uri = NULL;
 
358
        if (found == false) {
 
359
                DEBUG(0, ("MAPISTORE: no backend with namespace '%s' is available\n", namespace));
 
360
                retval = MAPISTORE_ERR_NOT_FOUND; 
 
361
                goto end;
 
362
        }
 
363
 
 
364
        context->backend_object = backend_object;
 
365
        context->backend = backends[i].backend;
 
366
        retval = context->backend->context.get_root_folder(backend_object, context, fid, &context->root_folder_object);
 
367
        if (retval != MAPISTORE_SUCCESS) {
 
368
                goto end;
 
369
        }
 
370
 
 
371
        context->ref_count = 1;
 
372
        context->uri = talloc_asprintf(context, "%s%s", namespace, uri);
 
373
        *context_p = context;
 
374
 
 
375
        (void) talloc_reference(mem_ctx, context);
 
376
 
 
377
end:
 
378
        talloc_unlink(NULL, context);
 
379
 
 
380
        return retval;
 
381
}
 
382
 
 
383
 
 
384
enum mapistore_error mapistore_backend_create_root_folder(const char *username, enum mapistore_context_role ctx_role, uint64_t fid, const char *name, TALLOC_CTX *mem_ctx, char **mapistore_urip)
 
385
{
 
386
        enum mapistore_error            retval = MAPISTORE_ERR_NOT_FOUND;
 
387
        int                             i;
 
388
 
 
389
        for (i = 0; retval == MAPISTORE_ERR_NOT_FOUND && i < num_backends; i++) {
 
390
                retval = backends[i].backend->backend.create_root_folder(username, ctx_role, fid, name, mem_ctx, mapistore_urip);
 
391
        }
 
392
 
 
393
        return retval;
 
394
}
 
395
 
 
396
/**
 
397
   \details Increase the ref count associated to a given backend
 
398
 
 
399
   \param bctx pointer to the backend context
 
400
 
 
401
   \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
 
402
 */
 
403
_PUBLIC_ enum mapistore_error mapistore_backend_add_ref_count(struct backend_context *bctx)
 
404
{
 
405
        if (!bctx) {
 
406
                return MAPISTORE_ERROR;
 
407
        }
 
408
 
 
409
        bctx->ref_count += 1;
 
410
 
 
411
        return MAPISTORE_SUCCESS;
 
412
}
 
413
 
 
414
 
 
415
/**
 
416
   \details Delete a context from the specified backend
 
417
 
 
418
   \param bctx pointer to the backend context
 
419
 
 
420
   \return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
 
421
 */
 
422
_PUBLIC_ enum mapistore_error mapistore_backend_delete_context(struct backend_context *bctx)
 
423
{
 
424
        if (bctx->ref_count) {
 
425
                bctx->ref_count -= 1;
 
426
                return MAPISTORE_ERR_REF_COUNT;
 
427
        }
 
428
 
 
429
        talloc_free(bctx);
 
430
        
 
431
        return MAPISTORE_SUCCESS;
 
432
}
 
433
 
 
434
 
 
435
/**
 
436
   \details find the context matching given context identifier
 
437
 
 
438
   \param backend_list_ctx pointer to the backend context list
 
439
   \param context_id the context identifier to search
 
440
 
 
441
   \return Pointer to the mapistore_backend context on success, otherwise NULL
 
442
 */
 
443
_PUBLIC_ struct backend_context *mapistore_backend_lookup(struct backend_context_list *backend_list_ctx,
 
444
                                                          uint32_t context_id)
 
445
{
 
446
        struct backend_context_list     *el;
 
447
 
 
448
        /* Sanity checks */
 
449
        if (!backend_list_ctx) return NULL;
 
450
 
 
451
        for (el = backend_list_ctx; el; el = el->next) {
 
452
                if (el->ctx && el->ctx->context_id == context_id) {
 
453
                        return el->ctx;
 
454
                }
 
455
        }
 
456
 
 
457
        return NULL;
 
458
}
 
459
 
 
460
/**
 
461
   \details find the context matching given uri string
 
462
 
 
463
   \param backend_list_ctx pointer to the backend context list
 
464
   \param uri the uri string to search
 
465
 
 
466
   \return Pointer to the mapistore_backend context on success,
 
467
   otherwise NULL
 
468
 */
 
469
_PUBLIC_ struct backend_context *mapistore_backend_lookup_by_uri(struct backend_context_list *backend_list_ctx,
 
470
                                                                 const char *uri)
 
471
{
 
472
        struct backend_context_list     *el;
 
473
 
 
474
        /* sanity checks */
 
475
        if (!backend_list_ctx) return NULL;
 
476
        if (!uri) return NULL;
 
477
 
 
478
        for (el = backend_list_ctx; el; el = el->next) {
 
479
                if (el->ctx && el->ctx->uri &&
 
480
                    !strcmp(el->ctx->uri, uri)) {
 
481
                        return el->ctx;
 
482
                }
 
483
        }
 
484
        
 
485
        return NULL;
 
486
}
 
487
 
 
488
/**
 
489
   \details Return a pointer on backend functions given its name
 
490
 
 
491
   \param mem_ctx pointer to the memory context
 
492
   \param name the backend name to lookup
 
493
 
 
494
   \return Allocated pointer to the mapistore_backend context on success,
 
495
   otherwise NULL
 
496
 */
 
497
_PUBLIC_ struct backend_context *mapistore_backend_lookup_by_name(TALLOC_CTX *mem_ctx, const char *name)
 
498
{
 
499
        struct backend_context  *context = NULL;
497
500
        int                     i;
498
501
 
 
502
        /* Sanity checks */
 
503
        if (!name) return NULL;
 
504
 
499
505
        for (i = 0; i < num_backends; i++) {
500
 
                if (backends[i].backend->uri_namespace &&
501
 
                    !strcmp(uri_namespace, backends[i].backend->uri_namespace)) {
502
 
                        retval = backends[i].backend->op_db_create_uri(mem_ctx, index, username, &_uri);
503
 
                        if (retval == MAPISTORE_SUCCESS) {
504
 
                                *uri = _uri;
505
 
                                return retval;
506
 
                        }
507
 
                }
508
 
        }
509
 
 
510
 
        return MAPISTORE_ERR_NOT_FOUND;
511
 
}
512
 
 
513
 
 
514
 
enum MAPISTORE_ERROR mapistore_backend_root_mkdir(struct backend_context *bctx, enum MAPISTORE_DFLT_FOLDERS system_idx,
515
 
                                                  const char *mapistore_uri, const char *folder_name)
516
 
{
517
 
        return bctx->backend->op_db_mkdir(bctx->private_data, system_idx, mapistore_uri, folder_name);
518
 
}
519
 
 
520
 
 
521
 
 /**
522
 
    \details find the context matching given context identifier
523
 
 
524
 
    \param backend_list_ctx pointer to the backend context list
525
 
    \param context_id the context identifier to search
526
 
 
527
 
    \return Pointer to the mapistore_backend context on success, otherwise NULL
528
 
  */
529
 
 _PUBLIC_ struct backend_context *mapistore_backend_lookup(struct backend_context_list *backend_list_ctx,
530
 
                                                           uint32_t context_id)
531
 
 {
532
 
         struct backend_context_list    *el;
533
 
 
534
 
         /* Sanity checks */
535
 
         if (!backend_list_ctx) return NULL;
536
 
 
537
 
         for (el = backend_list_ctx; el; el = el->next) {
538
 
                 if (el->ctx && el->ctx->context_id == context_id) {
539
 
                         return el->ctx;
540
 
                 }
541
 
         }
542
 
 
543
 
         return NULL;
544
 
 }
545
 
 
546
 
 
547
 
 /**
548
 
    \details find the context matching given uri string
549
 
 
550
 
    \param backend_list_ctx pointer to the backend context list
551
 
    \param uri the uri string to search
552
 
 
553
 
    \return Pointer to the mapistore_backend context on success,
554
 
    otherwise NULL
555
 
  */
556
 
 _PUBLIC_ struct backend_context *mapistore_backend_lookup_by_uri(struct backend_context_list *backend_list_ctx,
557
 
                                                                  const char *uri)
558
 
 {
559
 
         struct backend_context_list    *el;
560
 
 
561
 
         /* sanity checks */
562
 
         if (!backend_list_ctx) return NULL;
563
 
         if (!uri) return NULL;
564
 
 
565
 
         for (el = backend_list_ctx; el; el = el->next) {
566
 
                 if (el->ctx && el->ctx->uri &&
567
 
                     !strcmp(el->ctx->uri, uri)) {
568
 
                         return el->ctx;
569
 
                 }
570
 
         }
571
 
 
572
 
         return NULL;
573
 
 }
574
 
 
575
 
 enum MAPISTORE_ERROR mapistore_get_path(struct backend_context *bctx, const char *uri, uint8_t type, char **path)
576
 
 {
577
 
         enum MAPISTORE_ERROR   ret;
578
 
         char                   *bpath = NULL;
579
 
 
580
 
         /* Sanity checks */
581
 
         MAPISTORE_RETVAL_IF(!bctx, MAPISTORE_ERR_NOT_INITIALIZED, NULL);
582
 
         MAPISTORE_RETVAL_IF(!uri, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
583
 
         MAPISTORE_RETVAL_IF(!path, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
584
 
 
585
 
         ret = bctx->backend->get_path(bctx->private_data, uri, type, &bpath);
586
 
 
587
 
         if (!ret) {
588
 
                 *path = talloc_asprintf(bctx, "%s%s", bctx->backend->uri_namespace, bpath);
589
 
         } else {
590
 
                 *path = NULL;
591
 
         }
592
 
 
593
 
         return ret;
594
 
 }
595
 
 
596
 
 
597
 
 /* enum MAPISTORE_ERROR mapistore_backend_opendir(struct backend_context *bctx, uint64_t parent_fid, uint64_t fid) */
598
 
 /* { */
599
 
 /*      return bctx->backend->op_opendir(bctx->private_data, parent_fid, fid); */
600
 
 /* } */
601
 
 
602
 
enum MAPISTORE_ERROR mapistore_backend_opendir(struct backend_context *bctx, 
603
 
                                               const char *parent_uri, 
604
 
                                               const char *folder_uri)
605
 
{
606
 
        return bctx->backend->op_opendir(bctx->private_data, parent_uri, folder_uri);
607
 
}
608
 
 
609
 
 
610
 
enum MAPISTORE_ERROR mapistore_backend_mkdir(struct backend_context *bctx,
611
 
                                             char *parent_uri,
612
 
                                             const char *folder_name,
613
 
                                             const char *folder_desc,
614
 
                                             enum FOLDER_TYPE folder_type,
615
 
                                             char **folder_uri)
616
 
{
617
 
        enum MAPISTORE_ERROR    retval;
618
 
 
619
 
        retval = bctx->backend->op_mkdir(bctx->private_data, parent_uri, folder_name, folder_desc, folder_type, folder_uri);
620
 
 
621
 
        return retval;
622
 
}
623
 
 
624
 
enum MAPISTORE_ERROR mapistore_backend_closedir(struct backend_context *bctx, 
625
 
                                               const char *folder_uri)
626
 
{
627
 
        return bctx->backend->op_closedir(bctx->private_data, folder_uri);
628
 
}
629
 
 
630
 
 enum MAPISTORE_ERROR mapistore_backend_rmdir(struct backend_context *bctx,
631
 
                                              const char *parent_uri,
632
 
                                              const char *folder_uri)
633
 
 {
634
 
         return bctx->backend->op_rmdir(bctx->private_data, parent_uri, folder_uri);
635
 
 }
636
 
 
637
 
 
638
 
 enum MAPISTORE_ERROR mapistore_backend_readdir_count(struct backend_context *bctx, 
639
 
                                                      const char *folder_uri,
640
 
                                                      enum MAPISTORE_TABLE_TYPE table_type, 
641
 
                                                      uint32_t *RowCount)
642
 
 {
643
 
         enum MAPISTORE_ERROR           retval;
644
 
         uint32_t                       count = 0;
645
 
 
646
 
         retval = bctx->backend->op_readdir_count(bctx->private_data, folder_uri, table_type, &count);
647
 
         *RowCount = count;
648
 
 
649
 
         return retval;
650
 
 }
651
 
 
652
 
 
653
 
 enum MAPISTORE_ERROR mapistore_backend_get_table_property(struct backend_context *bctx, 
654
 
                                                           const char * folder_uri,
655
 
                                                           enum MAPISTORE_TABLE_TYPE table_type,
656
 
                                                           uint32_t pos, 
657
 
                                                           enum MAPITAGS proptag, 
658
 
                                                           void **data)
659
 
 {
660
 
         return bctx->backend->op_get_table_property(bctx->private_data, folder_uri, table_type, pos, proptag, data);
661
 
 }
662
 
 
663
 
 
664
 
 enum MAPISTORE_ERROR mapistore_backend_openmessage(struct backend_context *bctx, 
665
 
                                                    const char *parent_uri,
666
 
                                                    const char *message_uri,
667
 
                                                    struct mapistore_message *msg)
668
 
 {
669
 
         return bctx->backend->op_openmessage(bctx->private_data, parent_uri, message_uri, msg);
670
 
 }
671
 
 
672
 
 
673
 
 enum MAPISTORE_ERROR mapistore_backend_createmessage(struct backend_context *bctx, 
674
 
                                                      const char *parent_uri,
675
 
                                                      char **message_uri, 
676
 
                                                      bool *uri_register)
677
 
 {
678
 
         return bctx->backend->op_createmessage(bctx->private_data, parent_uri, message_uri, uri_register);
679
 
 }
680
 
 
681
 
 
682
 
 enum MAPISTORE_ERROR mapistore_backend_savechangesmessage(struct backend_context *bctx, 
683
 
                                                           const char *message_uri, 
684
 
                                                           uint8_t flags)
685
 
 {
686
 
         return bctx->backend->op_savechangesmessage(bctx->private_data, message_uri, flags);
687
 
 }
688
 
 
689
 
 
690
 
 enum MAPISTORE_ERROR mapistore_backend_submitmessage(struct backend_context *bctx, 
691
 
                                                      const char *message_uri, 
692
 
                                                      uint8_t flags)
693
 
 {
694
 
         return bctx->backend->op_submitmessage(bctx->private_data, message_uri, flags);
695
 
 }
696
 
 
697
 
 
698
 
 enum MAPISTORE_ERROR mapistore_backend_getprops(struct backend_context *bctx, 
699
 
                                                 const char *uri,
700
 
                                                 uint8_t type, 
701
 
                                                 struct SPropTagArray *SPropTagArray, 
702
 
                                                 struct SRow *aRow)
703
 
 {
704
 
         return bctx->backend->op_getprops(bctx->private_data, uri, type, SPropTagArray, aRow);
705
 
 }
706
 
 
707
 
 
708
 
 enum MAPISTORE_ERROR mapistore_backend_get_uri_by_name(struct backend_context *bctx,
709
 
                                                        const char *parent_uri,
710
 
                                                        const char *name,
711
 
                                                        char **uri)
712
 
 {
713
 
         return bctx->backend->op_get_uri_by_name(bctx->private_data, parent_uri, name, uri);
714
 
 }
715
 
 
716
 
 
717
 
 
718
 
 enum MAPISTORE_ERROR mapistore_backend_setprops(struct backend_context *bctx, 
719
 
                                                 const char *uri, 
720
 
                                                 uint8_t type, 
721
 
                                                 struct SRow *aRow)
722
 
 {
723
 
         return bctx->backend->op_setprops(bctx->private_data, uri, type, aRow);
724
 
 }
725
 
 
726
 
 enum MAPISTORE_ERROR mapistore_backend_deletemessage(struct backend_context *bctx, 
727
 
                                                      const char *message_uri, 
728
 
                                                      enum MAPISTORE_DELETION_TYPE deletion_type)
729
 
{
730
 
        return bctx->backend->op_deletemessage(bctx->private_data, message_uri, deletion_type);
 
506
                if (backends[i].backend && !strcmp(backends[i].backend->backend.name, name)) {
 
507
                        context = talloc_zero(mem_ctx, struct backend_context);
 
508
                        context->backend = backends[i].backend;
 
509
                        context->ref_count = 0;
 
510
                        context->uri = NULL;
 
511
 
 
512
                        return context;
 
513
                }
 
514
        }
 
515
        return NULL;
 
516
}
 
517
 
 
518
 
 
519
enum mapistore_error mapistore_backend_get_path(struct backend_context *bctx, TALLOC_CTX *mem_ctx, uint64_t fmid, char **path)
 
520
{
 
521
        enum mapistore_error    ret;
 
522
        char                    *bpath = NULL;
 
523
 
 
524
        ret = bctx->backend->context.get_path(bctx->backend_object, mem_ctx, fmid, &bpath);
 
525
 
 
526
        if (!ret) {
 
527
                *path = talloc_asprintf(mem_ctx, "%s%s", bctx->backend->backend.namespace, bpath);
 
528
        } else {
 
529
                *path = NULL;
 
530
        }
 
531
 
 
532
        return ret;
 
533
}
 
534
 
 
535
enum mapistore_error mapistore_backend_folder_open_folder(struct backend_context *bctx, void *folder, TALLOC_CTX *mem_ctx, uint64_t fid, void **child_folder)
 
536
{
 
537
        return bctx->backend->folder.open_folder(folder, mem_ctx, fid, child_folder);
 
538
}
 
539
 
 
540
enum mapistore_error mapistore_backend_folder_create_folder(struct backend_context *bctx, void *folder,
 
541
                                           TALLOC_CTX *mem_ctx, uint64_t fid, struct SRow *aRow, void **child_folder)
 
542
{
 
543
        return bctx->backend->folder.create_folder(folder, mem_ctx, fid, aRow, child_folder);
 
544
}
 
545
 
 
546
enum mapistore_error mapistore_backend_folder_delete(struct backend_context *bctx, void *folder)
 
547
{
 
548
        return bctx->backend->folder.delete(folder);
 
549
}
 
550
 
 
551
enum mapistore_error mapistore_backend_folder_open_message(struct backend_context *bctx, void *folder,
 
552
                                          TALLOC_CTX *mem_ctx, uint64_t mid, bool read_write, void **messagep)
 
553
{
 
554
        return bctx->backend->folder.open_message(folder, mem_ctx, mid, read_write, messagep);
 
555
}
 
556
 
 
557
enum mapistore_error mapistore_backend_folder_create_message(struct backend_context *bctx, void *folder, TALLOC_CTX *mem_ctx, uint64_t mid, uint8_t associated, void **messagep)
 
558
{
 
559
        return bctx->backend->folder.create_message(folder, mem_ctx, mid, associated, messagep);
 
560
}
 
561
 
 
562
enum mapistore_error mapistore_backend_folder_delete_message(struct backend_context *bctx, void *folder, uint64_t mid, uint8_t flags)
 
563
{
 
564
        return bctx->backend->folder.delete_message(folder, mid, flags);
 
565
}
 
566
 
 
567
enum mapistore_error mapistore_backend_folder_move_copy_messages(struct backend_context *bctx, void *target_folder, void *source_folder, uint32_t mid_count, uint64_t *source_mids, uint64_t *target_mids, struct Binary_r **target_change_keys, uint8_t want_copy)
 
568
{
 
569
        return bctx->backend->folder.move_copy_messages(target_folder, source_folder, mid_count, source_mids, target_mids, target_change_keys, want_copy);
 
570
}
 
571
 
 
572
enum mapistore_error mapistore_backend_folder_get_deleted_fmids(struct backend_context *bctx, void *folder, TALLOC_CTX *mem_ctx, enum mapistore_table_type table_type, uint64_t change_num, struct I8Array_r **fmidsp, uint64_t *cnp)
 
573
{
 
574
        return bctx->backend->folder.get_deleted_fmids(folder, mem_ctx, table_type, change_num, fmidsp, cnp);
 
575
}
 
576
 
 
577
enum mapistore_error mapistore_backend_folder_get_child_count(struct backend_context *bctx, void *folder, enum mapistore_table_type table_type, uint32_t *RowCount)
 
578
{
 
579
        return bctx->backend->folder.get_child_count(folder, table_type, RowCount);
 
580
}
 
581
 
 
582
enum mapistore_error mapistore_backend_folder_get_child_fid_by_name(struct backend_context *bctx, void *folder, const char *name, uint64_t *fidp)
 
583
{
 
584
        enum mapistore_error            ret = MAPISTORE_SUCCESS;
 
585
        struct mapi_SRestriction        name_restriction;
 
586
        void                            *table;
 
587
        uint8_t                         status;
 
588
        TALLOC_CTX                      *mem_ctx;
 
589
        enum MAPITAGS                   col;
 
590
        struct mapistore_property_data  *data_pointers;
 
591
        uint32_t                        row_count;
 
592
 
 
593
        mem_ctx = talloc_zero(NULL, TALLOC_CTX);
 
594
        
 
595
        if (mapistore_backend_folder_open_table(bctx, folder, mem_ctx, MAPISTORE_FOLDER_TABLE, 0, &table, &row_count)) {
 
596
                talloc_free(mem_ctx);
 
597
                return MAPISTORE_ERROR;
 
598
        }
 
599
 
 
600
        name_restriction.rt = RES_PROPERTY;
 
601
        name_restriction.res.resProperty.relop = RELOP_EQ;
 
602
        name_restriction.res.resProperty.ulPropTag = PR_DISPLAY_NAME_UNICODE;
 
603
        name_restriction.res.resProperty.lpProp.ulPropTag = name_restriction.res.resProperty.ulPropTag;
 
604
        name_restriction.res.resProperty.lpProp.value.lpszW = name;
 
605
 
 
606
        col = PR_FID;
 
607
        mapistore_backend_table_set_columns(bctx, table, 1, &col);
 
608
        mapistore_backend_table_set_restrictions(bctx, table, &name_restriction, &status);
 
609
        ret = mapistore_backend_table_get_row(bctx, table, mem_ctx, MAPISTORE_PREFILTERED_QUERY, 0, &data_pointers);
 
610
        if (!ret) {
 
611
                if (data_pointers[0].error) {
 
612
                        ret = MAPISTORE_ERROR;
 
613
                }
 
614
                else {
 
615
                        *fidp = *(uint64_t *) data_pointers[0].data;
 
616
                }
 
617
        }
 
618
 
 
619
        talloc_free(mem_ctx);
 
620
 
 
621
        return ret;
 
622
}
 
623
 
 
624
enum mapistore_error mapistore_backend_folder_open_table(struct backend_context *bctx, void *folder,
 
625
                                                         TALLOC_CTX *mem_ctx, enum mapistore_table_type table_type, uint32_t handle_id, void **table, uint32_t *row_count)
 
626
{
 
627
        return bctx->backend->folder.open_table(folder, mem_ctx, table_type, handle_id, table, row_count);
 
628
}
 
629
 
 
630
enum mapistore_error mapistore_backend_folder_modify_permissions(struct backend_context *bctx, void *folder,
 
631
                                                uint8_t flags, uint16_t pcount, struct PermissionData *permissions)
 
632
{
 
633
        return bctx->backend->folder.modify_permissions(folder, flags, pcount, permissions);
 
634
}
 
635
 
 
636
enum mapistore_error mapistore_backend_message_get_message_data(struct backend_context *bctx, void *message, TALLOC_CTX *mem_ctx, struct mapistore_message **msg)
 
637
{
 
638
        return bctx->backend->message.get_message_data(message, mem_ctx, msg);
 
639
}
 
640
 
 
641
enum mapistore_error mapistore_backend_message_modify_recipients(struct backend_context *bctx, void *message, struct SPropTagArray *columns, uint16_t count, struct mapistore_message_recipient *recipients)
 
642
{
 
643
        return bctx->backend->message.modify_recipients(message, columns, count, recipients);
 
644
}
 
645
 
 
646
enum mapistore_error mapistore_backend_message_set_read_flag(struct backend_context *bctx, void *message, uint8_t flag)
 
647
{
 
648
        return bctx->backend->message.set_read_flag(message, flag);
 
649
}
 
650
 
 
651
enum mapistore_error mapistore_backend_message_save(struct backend_context *bctx, void *message)
 
652
{
 
653
        return bctx->backend->message.save(message);
 
654
}
 
655
 
 
656
enum mapistore_error mapistore_backend_message_submit(struct backend_context *bctx, void *message, enum SubmitFlags flags)
 
657
{
 
658
        return bctx->backend->message.submit(message, flags);
 
659
}
 
660
 
 
661
enum mapistore_error mapistore_backend_message_open_attachment(struct backend_context *bctx, void *message, TALLOC_CTX *mem_ctx, uint32_t aid, void **attachment)
 
662
{
 
663
        return bctx->backend->message.open_attachment(message, mem_ctx, aid, attachment);
 
664
}
 
665
 
 
666
enum mapistore_error mapistore_backend_message_create_attachment(struct backend_context *bctx, void *message, TALLOC_CTX *mem_ctx, void **attachment, uint32_t *aid)
 
667
{
 
668
        return bctx->backend->message.create_attachment(message, mem_ctx, attachment, aid);
 
669
}
 
670
 
 
671
enum mapistore_error mapistore_backend_message_get_attachment_table(struct backend_context *bctx, void *message, TALLOC_CTX *mem_ctx, void **table, uint32_t *row_count)
 
672
{
 
673
        return bctx->backend->message.get_attachment_table(message, mem_ctx, table, row_count);
 
674
}
 
675
 
 
676
enum mapistore_error mapistore_backend_message_attachment_open_embedded_message(struct backend_context *bctx, void *message, TALLOC_CTX *mem_ctx, void **embedded_message, uint64_t *mid, struct mapistore_message **msg)
 
677
{
 
678
        return bctx->backend->message.open_embedded_message(message, mem_ctx, embedded_message, mid, msg);
 
679
}
 
680
 
 
681
enum mapistore_error mapistore_backend_table_get_available_properties(struct backend_context *bctx, void *table, TALLOC_CTX *mem_ctx, struct SPropTagArray **propertiesp)
 
682
{
 
683
        return bctx->backend->table.get_available_properties(table, mem_ctx, propertiesp);
 
684
}
 
685
 
 
686
enum mapistore_error mapistore_backend_table_set_columns(struct backend_context *bctx, void *table, uint16_t count, enum MAPITAGS *properties)
 
687
{
 
688
        return bctx->backend->table.set_columns(table, count, properties);
 
689
}
 
690
 
 
691
enum mapistore_error mapistore_backend_table_set_restrictions(struct backend_context *bctx, void *table, struct mapi_SRestriction *restrictions, uint8_t *table_status)
 
692
{
 
693
        return bctx->backend->table.set_restrictions(table, restrictions, table_status);
 
694
}
 
695
 
 
696
enum mapistore_error mapistore_backend_table_set_sort_order(struct backend_context *bctx, void *table, struct SSortOrderSet *sort_order, uint8_t *table_status)
 
697
{
 
698
        return bctx->backend->table.set_sort_order(table, sort_order, table_status);
 
699
}
 
700
 
 
701
enum mapistore_error mapistore_backend_table_get_row(struct backend_context *bctx, void *table, TALLOC_CTX *mem_ctx,
 
702
                                                     enum mapistore_query_type query_type, uint32_t rowid,
 
703
                                                     struct mapistore_property_data **data)
 
704
{
 
705
        return bctx->backend->table.get_row(table, mem_ctx, query_type, rowid, data);
 
706
}
 
707
 
 
708
enum mapistore_error mapistore_backend_table_get_row_count(struct backend_context *bctx, void *table, enum mapistore_query_type query_type, uint32_t *row_countp)
 
709
{
 
710
        return bctx->backend->table.get_row_count(table, query_type, row_countp);
 
711
}
 
712
 
 
713
enum mapistore_error mapistore_backend_table_handle_destructor(struct backend_context *bctx, void *table, uint32_t handle_id)
 
714
{
 
715
        return bctx->backend->table.handle_destructor(table, handle_id);
 
716
}
 
717
 
 
718
enum mapistore_error mapistore_backend_properties_get_available_properties(struct backend_context *bctx, void *object, TALLOC_CTX *mem_ctx, struct SPropTagArray **propertiesp)
 
719
{
 
720
        return bctx->backend->properties.get_available_properties(object, mem_ctx, propertiesp);
 
721
}
 
722
 
 
723
enum mapistore_error mapistore_backend_properties_get_properties(struct backend_context *bctx,
 
724
                                                void *object, TALLOC_CTX *mem_ctx,
 
725
                                                uint16_t count, enum MAPITAGS
 
726
                                                *properties,
 
727
                                                struct mapistore_property_data *data)
 
728
{
 
729
        return bctx->backend->properties.get_properties(object, mem_ctx, count, properties, data);
 
730
}
 
731
 
 
732
enum mapistore_error mapistore_backend_properties_set_properties(struct backend_context *bctx, void *object, struct SRow *aRow)
 
733
{
 
734
        return bctx->backend->properties.set_properties(object, aRow);
 
735
}
 
736
 
 
737
enum mapistore_error mapistore_backend_manager_generate_uri(struct backend_context *bctx, TALLOC_CTX *mem_ctx, 
 
738
                                           const char *username, const char *folder, 
 
739
                                           const char *message, const char *root_uri, char **uri)
 
740
{
 
741
        return bctx->backend->manager.generate_uri(mem_ctx, username, folder, message, root_uri, uri);
731
742
}