164
\details Increase the reference counter of an existing context
166
\param mstore_ctx pointer to the mapistore context
167
\param contex_id the context identifier referencing the context to
170
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
172
_PUBLIC_ int mapistore_add_context_ref_count(struct mapistore_context *mstore_ctx,
175
struct backend_context *backend_ctx;
179
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
181
if (context_id == -1) return MAPISTORE_ERROR;
183
/* Step 0. Ensure the context exists */
184
DEBUG(0, ("mapistore_add_context_ref_count: context_is to increment is %d\n", context_id));
185
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
186
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
188
/* Step 1. Increment the ref count */
189
retval = mapistore_backend_add_ref_count(backend_ctx);
196
\details Search for an existing context given its uri
198
\param mstore_ctx pointer to the mapistore context
199
\param uri the URI to lookup
200
\param context_id pointer to the context identifier to return
202
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
204
_PUBLIC_ int mapistore_search_context_by_uri(struct mapistore_context *mstore_ctx,
206
uint32_t *context_id)
208
struct backend_context *backend_ctx;
211
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
213
if (!uri) return MAPISTORE_ERROR;
215
backend_ctx = mapistore_backend_lookup_by_uri(mstore_ctx->context_list, uri);
216
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_NOT_FOUND, NULL);
218
*context_id = backend_ctx->context_id;
219
return MAPISTORE_SUCCESS;
159
224
\details Delete an existing connection context from mapistore
161
226
\param mstore_ctx pointer to the mapistore context
167
232
_PUBLIC_ int mapistore_del_context(struct mapistore_context *mstore_ctx,
168
233
uint32_t context_id)
170
struct backend_context_list *el;
235
struct backend_context_list *backend_list;
236
struct backend_context *backend_ctx;
172
238
bool found = false;
174
240
/* Sanity checks */
175
if (!mstore_ctx) return MAPISTORE_ERR_NOT_INITIALIZED;
176
if (!mstore_ctx->processing_ctx) return MAPISTORE_ERR_NOT_INITIALIZED;
177
if (!mstore_ctx->context_list) return MAPISTORE_ERR_NOT_INITIALIZED;
241
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
243
if (context_id == -1) return MAPISTORE_ERROR;
179
245
/* Step 0. Ensure the context exists */
180
for (el = mstore_ctx->context_list; el; el = el->next) {
181
if (el->ctx && el->ctx->context_id == context_id) {
246
DEBUG(0, ("mapistore_del_context: context_id to del is %d\n", context_id));
247
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
248
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
250
/* search the backend_list item */
251
for (backend_list = mstore_ctx->context_list; backend_list; backend_list = backend_list->next) {
252
if (backend_list->ctx->context_id == context_id) {
186
if (found == false) return MAPISTORE_ERR_INVALID_PARAMETER;
257
if (found == false) {
258
return MAPISTORE_ERROR;
188
261
/* Step 1. Delete the context within backend */
189
retval = mapistore_backend_delete_context(el->ctx);
190
if (retval) return retval;
192
/* Step 2. Delete the context from the processing layer */
194
/* Step 2. Add the free'd context id to the free list */
195
retval = mapistore_free_context_id(mstore_ctx->processing_ctx, context_id);
262
retval = mapistore_backend_delete_context(backend_ctx);
264
case MAPISTORE_ERR_REF_COUNT:
265
return MAPISTORE_SUCCESS;
266
case MAPISTORE_SUCCESS:
267
DLIST_REMOVE(mstore_ctx->context_list, backend_list);
268
/* Step 2. Add the free'd context id to the free list */
269
retval = mapistore_free_context_id(mstore_ctx->processing_ctx, context_id);
280
\details Release private backend data associated a folder / message
281
opened within the mapistore backend
283
\param mstore_ctx pointer to the mapistore context
284
\param context_id the context identifier referencing the backend
285
\param fmid a folder or message identifier
286
\param type the type of fmid, either MAPISTORE_FOLDER or MAPISTORE_MESSAGE
288
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
290
_PUBLIC_ int mapistore_release_record(struct mapistore_context *mstore_ctx,
295
struct backend_context *backend_ctx;
299
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
301
/* Step 1. Search the context */
302
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
303
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
305
/* Step 2. Call backend release_record */
306
ret = mapistore_backend_release_record(backend_ctx, fmid, type);
308
return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
313
\details Associate an indexing context to a mapistore context
315
\param mstore_ctx pointer to the mapistore context
316
\param username account name referencing the indexing record
317
\param context_id the context identifier referencing the context to
320
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
322
_PUBLIC_ int mapistore_add_context_indexing(struct mapistore_context *mstore_ctx,
323
const char *username,
326
struct indexing_context_list *indexing_ctx;
327
struct backend_context *backend_ctx;
330
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
331
MAPISTORE_RETVAL_IF(!username, MAPISTORE_ERROR, NULL);
332
MAPISTORE_RETVAL_IF(context_id == -1, MAPISTORE_ERROR, NULL);
334
/* Step 0. Ensure the context exists */
335
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
336
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
337
/* If the indexing pointer is already existing, return success */
338
MAPISTORE_RETVAL_IF(backend_ctx->indexing, MAPISTORE_SUCCESS, NULL);
340
/* Step 1. Search the indexing record */
341
indexing_ctx = mapistore_indexing_search(mstore_ctx, username);
342
MAPISTORE_RETVAL_IF(!indexing_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
344
/* Step 2. Reference the indexing record within backend context */
345
backend_ctx->indexing = indexing_ctx;
347
/* Step 3. Increment the indexing ref counter */
348
mapistore_indexing_add_ref_count(indexing_ctx);
350
DEBUG(0, ("mapistore_add_context_indexing username: %s\n", backend_ctx->indexing->username));
352
return MAPISTORE_SUCCESS;
356
void mapistore_set_errno(int status)
201
363
\details return a string explaining what a mapistore error constant
233
395
return "Unknown error";
400
\details Open a directory in mapistore
402
\param mstore_ctx pointer to the mapistore context
403
\param context_id the context identifier referencing the backend
404
where the directory will be opened
405
\param parent_fid the parent folder identifier
406
\param fid folder identifier to open
408
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
410
_PUBLIC_ int mapistore_opendir(struct mapistore_context *mstore_ctx,
415
struct backend_context *backend_ctx;
419
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
421
/* Step 1. Search the context */
422
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
423
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
425
/* Step 2. Call backend opendir */
426
ret = mapistore_backend_opendir(backend_ctx, parent_fid, fid);
428
return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
433
\details Close a directory in mapistore
435
\param mstore_ctx pointer to the mapistore context
436
\param context_id the context identifier referencing the backend
437
where the directory has to be closed/released
438
\param fid the folder identifier referencing the folder to close
440
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
442
_PUBLIC_ int mapistore_closedir(struct mapistore_context *mstore_ctx,
446
struct backend_context *backend_ctx;
449
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
451
/* Step 0. Search the context */
452
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
453
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
455
/* mapistore_backend_closedir() */
457
return MAPISTORE_SUCCESS;
462
\details Create a directory in mapistore
464
\param mstore_ctx pointer to the mapistore context
465
\param context_id the context identifier referencing the backend
466
where the directory will be created
467
\param parent_fid the parent folder identifier
468
\param new_fid the folder identifier for the new folder
469
\param aRow pointer to MAPI data structures with properties to be
470
added to the new folder
472
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
474
_PUBLIC_ int mapistore_mkdir(struct mapistore_context *mstore_ctx,
480
struct backend_context *backend_ctx;
484
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
486
/* Step 1. Search the context */
487
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
488
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
490
/* Step 2. Call backend mkdir */
491
ret = mapistore_backend_mkdir(backend_ctx, parent_fid, fid, aRow);
493
return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
498
\details Remove a directory in mapistore
500
\param mstore_ctx pointer to the mapistore context
501
\param context_id the context identifier referencing the backend
502
\param parent_fid the parent folder identifier
503
\param fid the folder identifier representing the folder to delete
504
\param flags Flags specifying the rmdir operation behavior
505
(recursive for folders, messages)
507
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
509
_PUBLIC_ int mapistore_rmdir(struct mapistore_context *mstore_ctx,
515
struct backend_context *backend_ctx;
518
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
520
/* Step 0. Ensure the context exists */
521
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
522
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
524
return MAPISTORE_SUCCESS;
529
\details Retrieve the number of child folders within a mapistore
532
\param mstore_ctx pointer to the mapistore context
533
\param context_id the context identifier referencing the backend
534
\param fid the folder identifier
535
\param RowCount pointer to the count result to return
537
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
539
_PUBLIC_ int mapistore_get_folder_count(struct mapistore_context *mstore_ctx,
544
struct backend_context *backend_ctx;
548
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
550
/* Step 0. Ensure the context exists */
551
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
552
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
554
/* Step 2. Call backend opendir */
555
ret = mapistore_backend_readdir_count(backend_ctx, fid, MAPISTORE_FOLDER_TABLE, RowCount);
562
\details Retrieve the number of child messages within a mapistore folder
564
\param mstore_ctx pointer to the mapistore context
565
\param context_id the context identifier referencing the backend
566
\param fid the folder identifier
567
\param RowCount pointer to the count result to return
569
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
571
_PUBLIC_ int mapistore_get_message_count(struct mapistore_context *mstore_ctx,
576
struct backend_context *backend_ctx;
580
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
582
/* Step 0. Ensure the context exists */
583
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
584
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
586
/* Step 2. Call backend readdir_count */
587
ret = mapistore_backend_readdir_count(backend_ctx, fid, MAPISTORE_MESSAGE_TABLE, RowCount);
594
\details Retrieve a MAPI property from a table
596
\param mstore_ctx pointer to the mapistore context
597
\param context_id the context identifier referencing the backend
598
\param table_type the type of table (folders or messges)
599
\param fid the folder identifier where the search takes place
600
\param proptag the MAPI property tag to retrieve value for
601
\param pos the record position in search results
602
\param data pointer on pointer to the data the function returns
604
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
606
_PUBLIC_ int mapistore_get_table_property(struct mapistore_context *mstore_ctx,
614
struct backend_context *backend_ctx;
618
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
620
/* Step 1. Ensure the context exists */
621
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
622
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
624
/* Step 2. Call backend readdir */
625
ret = mapistore_backend_get_table_property(backend_ctx, fid, table_type, pos, proptag, data);
632
\details Open a message in mapistore
634
\param mstore_ctx pointer to the mapistore context
635
\param context_id the context identifier referencing the backend
636
where the directory will be opened
637
\param parent_fid the parent folder identifier
638
\param mid the message identifier to open
639
\param pointer to the mapistore_message structure
641
\return MAPISTORE SUCCESS on success, otherwise MAPISTORE errors
643
_PUBLIC_ int mapistore_openmessage(struct mapistore_context *mstore_ctx,
647
struct mapistore_message *msg)
649
struct backend_context *backend_ctx;
653
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
655
/* Step 1. Search the context */
656
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
657
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
659
/* Step 2. Call backend openmessage */
660
ret = mapistore_backend_openmessage(backend_ctx, parent_fid, mid, msg);
662
return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;
667
\details Get properties of a message/folder in mapistore
669
\param mstore_ctx pointer to the mapistore context
670
\param context_id the context identifier referencing the backend
671
where properties will be fetched
672
\param fmid the identifier referencing the message/folder
673
\param type the object type (folder or message)
674
\param properties pointer to the list of properties to fetch
675
\param aRow pointer to the SRow structure
677
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE errors
679
_PUBLIC_ int mapistore_getprops(struct mapistore_context *mstore_ctx,
683
struct SPropTagArray *properties,
686
struct backend_context *backend_ctx;
690
MAPISTORE_SANITY_CHECKS(mstore_ctx, NULL);
692
/* Step 1. Search the context */
693
backend_ctx = mapistore_backend_lookup(mstore_ctx->context_list, context_id);
694
MAPISTORE_RETVAL_IF(!backend_ctx, MAPISTORE_ERR_INVALID_PARAMETER, NULL);
696
/* Step 2. Call backend getprops */
697
ret = mapistore_backend_getprops(backend_ctx, fmid, type, properties, aRow);
699
return !ret ? MAPISTORE_SUCCESS : MAPISTORE_ERROR;